home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Makefiles / cvs.make < prev    next >
Encoding:
Text File  |  1994-02-16  |  5.2 KB  |  137 lines

  1. # cvs.make
  2. # by Mike Ferris
  3. # Part of MOKit
  4. # Copyright 1993, all rights reserved
  5.  
  6. # ABOUT MOKit
  7. # by Mike Ferris (mike@lorax.com)
  8. #
  9. # MOKit is a collection of useful and general objects.  Permission is 
  10. # granted by the author to use MOKit in your own programs in any way 
  11. # you see fit.  All other rights pertaining to the kit are reserved by the 
  12. # author including the right to sell these objects as objects,  as part 
  13. # of a LIBRARY, or as SOURCE CODE.  In plain English, I wish to retain 
  14. # rights to these objects as objects, but allow the use of the objects 
  15. # as pieces in a fully functional program.  Permission is also granted to 
  16. # redistribute the source code of MOKit for FREE as long as this copyright 
  17. # notice is left intact and unchanged.  NO WARRANTY is expressed or implied.  
  18. # The author will under no circumstances be held responsible for ANY 
  19. # consequences from the use of these objects.  Since you don't have to pay 
  20. # for them, and full source is provided, I think this is perfectly fair.
  21.  
  22. # About cvs.make
  23. #
  24. # This file is a HACK.  It is based on Art Isbell's cvs.postamble, 
  25. # but will work for whole directory trees, not just a PB directory.
  26. #
  27. # This file provides three make targets.  The first (cvsco) will look for any
  28. # CVS directories inside directories with one of a list of extensions
  29. # (ie nib and rtfd), and will tar all those CVS directories into a 
  30. # single archive in the directory you are running make from.  The second
  31. # target (cvsci) will unarchive those CVS directories back where they belong.
  32. # The third target (cvstrim) will look for any CVS directories inside 
  33. # directories with one of a another list of extensions (ie app, debug, profile, 
  34. # palette, or bundle) and remove those CVS directories it finds.
  35.  
  36. ######################### VARIABLE DEFINITIONS #########################
  37.  
  38. # You can customize these variables to affect the behavior of the targets
  39.  
  40. # The names of various programs used in this makefile
  41. CVS_TAR = gnutar
  42. CVS_ECHO = echo
  43. CVS_FIND = find
  44. CVS_RM = rm
  45. CVS_XARGS = xargs
  46.  
  47. # The name of the CVS directories
  48. CVS_ADMIN_DIR = CVS
  49.  
  50. # The name of the archive file to create
  51. CVS_ARCHIVE_FILE = CVSPackages.tar
  52.  
  53. # The extensions of file-package directories from which CVS directories 
  54. # must be archived.
  55. CVS_ARCHIVE_EXTS = nib rtfd
  56.  
  57. # The extensions of product directories from which it is desirable to 
  58. # trim CVS directories.
  59. CVS_TRIM_EXTS = debug app profile palette bundle
  60.  
  61. # Aliases used for make targets can be changed to suit you
  62. CVS_ARCHIVE_TARGET = cvspack
  63. CVS_RESTORE_TARGET = cvsunpack
  64. CVS_TRIM_TARGET = cvstrim
  65.  
  66. ######################### TARGET DEFINITIONS #########################
  67.  
  68. # This will create the tar archive empty, then find all the 
  69. # directories which match one of the CVS_ARCHIVE_EXTS extentions, and
  70. # append each one's CVS directory to the archive.
  71. $(CVS_ARCHIVE_TARGET):
  72.     @$(CVS_RM) -f $(CVS_ARCHIVE_FILE) ; \
  73.     $(CVS_TAR) -cf $(CVS_ARCHIVE_FILE) ; \
  74.     $(CVS_ECHO) "Archiving CVS administrative files from directories with " ; \
  75.     $(CVS_ECHO) "    extensions $(CVS_ARCHIVE_EXTS)." ; \
  76.     eval "findargs=\"\( \( \(\"" ; \
  77.     eval "donefirst=\"\"" ; \
  78.     for ext in $(CVS_TRIM_EXTS) ; do \
  79.         if [ $$donefirst ] ; then \
  80.             eval "findargs=\"$$findargs -o\"" ; \
  81.         fi ; \
  82.         eval "findargs=\"$$findargs -name \*.$$ext\"" ; \
  83.         eval "donefirst=\"YES\"" ; \
  84.     done ; \
  85.     eval "findargs=\"$$findargs \) -a -type d -a -prune \) -o\"" ; \
  86.     eval "findargs=\"$$findargs \( \(\"" ; \
  87.     eval "donefirst=\"\"" ; \
  88.     for ext in $(CVS_ARCHIVE_EXTS) ; do \
  89.         if [ $$donefirst ] ; then \
  90.             eval "findargs=\"$$findargs -o\"" ; \
  91.         fi ; \
  92.         eval "findargs=\"$$findargs -name \*.$$ext\"" ; \
  93.         eval "donefirst=\"YES\"" ; \
  94.     done ; \
  95.     eval "findargs=\"$$findargs \) -a -type d -a -print \) \)\"" ; \
  96.     for dir in `$(CVS_ECHO) $$findargs | $(CVS_XARGS) $(CVS_FIND) .` ; do \
  97.         if [ -d $$dir/$(CVS_ADMIN_DIR) ] ; then \
  98.             $(CVS_ECHO) "Archiving from $$dir." ; \
  99.             $(CVS_TAR) -uvf $(CVS_ARCHIVE_FILE) \
  100.                         `$(CVS_FIND) $$dir -name $(CVS_ADMIN_DIR) -a \
  101.                         -type d -print` ; \
  102.         fi ; \
  103.     done
  104.  
  105. # This just checks for the archive file, and if it's there, extracts it.
  106. $(CVS_RESTORE_TARGET):
  107.     @if [ ! -f $(CVS_ARCHIVE_FILE) ] ; then \
  108.         $(CVS_ECHO) -n "$(CVS_RESTORE_TARGET): " ; \
  109.         $(CVS_ECHO) "Can't find $(CVS_ARCHIVE_FILE)." ; \
  110.         exit ; \
  111.     fi ; \
  112.     $(CVS_ECHO) "Restoring file-package $(CVS_ADMIN_DIR) directories." ; \
  113.     $(CVS_TAR) -xvf $(CVS_ARCHIVE_FILE) ; \
  114.     $(CVS_RM) -f $(CVS_ARCHIVE_FILE)
  115.     
  116. # This will find all the directories with one of the CVS_TRIM_EXTS 
  117. # extentions and remove all CVS directories from them and their 
  118. # whole sub-trees
  119. $(CVS_TRIM_TARGET):
  120.     @$(CVS_ECHO) "Trimming CVS administrative files from directories with " ; \
  121.     $(CVS_ECHO) "   extensions $(CVS_TRIM_EXTS)." ; \
  122.     eval "findargs=\"\( \(\"" ; \
  123.     eval "donefirst=\"\"" ; \
  124.     for ext in $(CVS_TRIM_EXTS) ; do \
  125.         if [ $$donefirst ] ; then \
  126.             eval "findargs=\"$$findargs -o\"" ; \
  127.         fi ; \
  128.         eval "findargs=\"$$findargs -name \*.$$ext\"" ; \
  129.         eval "donefirst=\"YES\"" ; \
  130.     done ; \
  131.     eval "findargs=\"$$findargs \) -a -type d -a -print \)\"" ; \
  132.     for dir in `echo $$findargs | $(CVS_XARGS) $(CVS_FIND) .` ; do \
  133.         $(CVS_ECHO) "Trimming $$dir." ; \
  134.         $(CVS_FIND) $$dir -name $(CVS_ADMIN_DIR) -a -type d \
  135.                     -exec $(CVS_RM) -rf {} \; -prune ; \
  136.     done
  137.